package com.leetcode.LC;

public class LC504 {
    public String convertToBase7(int num) {
        if (num==0){
            return "0";
        }
        String tmp = "";
        if (num < 0) {
            tmp = "-";
            num = Math.abs(num);
        }
        StringBuilder builder = new StringBuilder();
        while (num > 0) {
            builder.append(num % 7 + "");
            num /= 7;
        }
        return builder.append(tmp).reverse().toString();
    }

    public static void main(String[] args) {
        System.out.println(new LC504().convertToBase7(-7));
    }
}
